package com.chengqs.jvm.t2;

import java.io.IOException;

/**
 * 堆内存
 * -Xmx64m -XX:+PrintGCDetails -verbose:gc
 */
public class Demo2_9_GC {
    public static void main(String[] args) throws IOException {
        // Eden区的User对象
        User user = new User();
        user.hashCode();
        System.out.println("创建User对象");
        System.in.read();
        // Eden区大小超载，转移到Survivor区
        User big = new User();
        big.bytes = new Byte[3 * 1024 * 1024];
        System.out.println("放入一个3m的对象");
        System.in.read();
        // Survivor区大小超载，转移到老年区
        big = null;
        System.out.println("垃圾回收");
        System.in.read();

    }

    public static class User {
        String name;
        int age;

        Byte[] bytes;
    }
}
